package cn.itsource.sentinelhandler;

import cn.itsource.domain.User;
import com.alibaba.csp.sentinel.slots.block.BlockException;
import org.springframework.web.bind.annotation.PathVariable;

public class GlobalHandler {

    // 必须是 public static 的
    public static User UserblockHandler(@PathVariable("id") Long id, BlockException exception){
        System.out.println("限流, 服务器繁忙！!!! ");
        exception.printStackTrace();
        return new User(-1l,"限流","服务器繁忙！");
    }

    // 必须是 public static 的
    public static User UserFallBackHandler(@PathVariable("id") Long id){
        System.out.println("熔断, 服务器出现异常！!!! ");

        return new User(-1l,"熔断","服务器出现异常！");
    }
}
